package com.test.pudamoney.util_pudamoney.analytics_pudamoney.bean_pudamoney

import com.appsflyer.AFInAppEventParameterName
import com.appsflyer.AFInAppEventType
import com.appsflyer.AppsFlyerLib
import com.appsflyer.AppsFlyerProperties
import com.test.pudamoney.activity_fragment_pudamoney.base_pudamoney.BaseApplication_pudamoney
import com.test.pudamoney.constant_pudamoney.Constant_pudamoney
import com.zhi.syc.data.util.ASNetworkUtil
import org.json.JSONObject

class ParamAppsflyerS2S_pudamoney(
    /** ip */
    var ip: String = "",
    /** 类型 */
    val type: String = "SAVE",
    /** appsflyer id */
    var appsflyer_id: String = "",
    /** 客户id */
    var customer_user_id: String = "",
    /** 事件名 */
    val eventName: String = AFInAppEventType.ADD_PAYMENT_INFO,
    /** 事件值 */
    var eventValue: String = "",
    /** 包名 */
    val bundleIdentifer: String = Constant_pudamoney.NAME,
    /** app版本号 */
    val app_version_name: String = Constant_pudamoney.APP_VERSION_NAME.toString(),
) : ParamBase_pudamoney() {
    init {
        //组装原有的appsflyer id
        this.appsflyer_id =
            AppsFlyerLib.getInstance().getAppsFlyerUID(BaseApplication_pudamoney.getApplication_pudamoney()) ?: ""

        //组装原有的客户id`
        val lastCuid = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.APP_USER_ID)
        this.customer_user_id = lastCuid ?: "${Constant_pudamoney.NAME}_${this.appsflyer_id}"

        //组装ip
        this.ip = ASNetworkUtil.getIPAddress(BaseApplication_pudamoney.getApplication_pudamoney()) ?: ""

        //组装事件
        var gEventValu = ""
        try {
            val jsonObject = JSONObject()
            jsonObject.put(AFInAppEventParameterName.SUCCESS, true)
            jsonObject.put(AFInAppEventParameterName.CONTENT, "review_pass")
            jsonObject.put(AFInAppEventParameterName.CONTENT_TYPE, "review_pass")
            gEventValu = jsonObject.toString()
        } catch (e: Exception) {
            e.printStackTrace()
        }
        this.eventValue = gEventValu
    }

}
